#pragma once

#define MAXPOPULATION	1

class CPop
{
public:
	CPop(void);
	CPop(CNodeTable* dp);
	~CPop(void);
	bool Initialize(int* sizeofPop,int npop,int nClass, int nItems, int genPop);

	Chro* pop[MAXPOPULATION];	//Population

	Chro* genPop;	//Population for generation !!!
						//Use single thread ..
	int nPopSize[MAXPOPULATION];		//length of each population
	int nPop[MAXPOPULATION];			//items in each population
	int nNumPop;						//# of Pop

	int nGenPop;						//items of gen Pop
	int nGenPopSize;					//length of gen Pop

	int nClass;			// # of class
	int nItems;			// # of item in each class
	CNodeTable* mdp;

	void QSort(int popID);
	void QuickSort(int low,int height,int bound,int popID);
	void QSortGenPop();
	void QuickSortGenPop(int low,int height,int bound);
	// reverse
	void QSortRev(int popID);
	void QuickSortRev(int low,int height,int bound,int popID);
	void QSortGenPopRev();
	void QuickSortGenPopRev(int low,int height,int bound);
	/// endofrev
	bool Replace(int popID);
	bool Select(Chro* ch0, Chro* ch1,int popID);

	bool Insert(Chro* ch0, int popID);

	bool TonermentSelection(Chro* ch0, Chro* ch1,int popID);
	bool GenerationReplaces(int popID);
	
	bool ForceInsert(Chro* ch0,int popNum);
	bool Contain(int popID, Chro* ch1);
	//CNodeTable* dp;


	void PrintPop(int popID);
	void PrintGenPop();
	void PrintChro(Chro* ch1);

	void Sharing();
	int VectorDistance();
	int HammingDistance();
	

};

